Statistic = {};
Statistic.date = new Date();
Statistic.MonthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
Statistic.CurrYear = function(){
	return this.date.getFullYear().toString();  
};  
Statistic.CurrMonth = function(){
	return this.date.getMonth();  
};  
Statistic.CurrDay = function(){
	return this.date.getDate();  
};  
Statistic.InitYearSelect = function(y){
	var years = this.CurrYear();
	var values = [];
	for (var i = years - 10; i <= years-1; i++) {
		values.push({'id':i,'name':i+'年'});
	}
	values.push({'id':years,'name':years+'年','selected':true});
	$(y).combobox('loadData',values);
};
Statistic.InitMonthSelect = function(y,m){
	var values = [];
	for (var i = 1; i < 13; i++) {
		values.push({'id':i,'name':i+'月'});
	}
	$(m).combobox('loadData',values).combobox('setValue',this.CurrMonth()+1);
};
Statistic.InitData = function(y,m,d){
	var year = $(y);  
	var month = $(m);  
	var day = $(d);  
	var mn = month.combobox('getValue');  
	var ye = year.combobox('getValue');  
	var n = Statistic.MonthDays[mn - 1];
	var values = [];
	if (ye % 4 == 0 && mn==2) {  
		n++;  
	}  
	for (var i = 1; i < n + 1; i++) {  
		if(i == Statistic.CurrDay()){
			values.push({'id':i,'name':i+'日','selected':true});
		}else{
			values.push({'id':i,'name':i+'日'});
		}
	}
	//month.combobox('disable');
	day.combobox('loadData',values);
	//day.combobox('disable');
};

function FlushDay(t,y,m,d){
	var year = $(y);
	var month = $(m);
	var mn = month.combobox('getValue');
	if(t == 'year'){
		month.combobox('setValue',1);
	}
	if(!d)return;
	var day = $(d);
	var ye = year.combobox('getValue');
	var n = Statistic.MonthDays[mn - 1];
	var values = [];
	if (ye % 4 == 0 && mn==2) {  
		n++;
	}  
	for (var i = 1; i < n + 1; i++) {
		if(i == 1){
			values.push({'id':i,'name':i+'日','selected':true});
		}else{
			values.push({'id':i,'name':i+'日'});
		}
	}
	day.combobox('loadData',values);
}

function initSelect(y,m,d){
	Statistic.InitYearSelect(y);
	Statistic.InitMonthSelect(y,m);
	if(d)Statistic.InitData(y,m,d);
}

function changeModel(model,y,m,d){
	switch(model){
	case 'year':
		$(m).combobox('disable');
		if(d)$(d).combobox('disable');
		break;
	case 'month':
		$(m).combobox('enable');
		if(d)$(d).combobox('disable');
		break;
	case 'week':
		$(m).combobox('enable');
		if(d)$(d).combobox('enable');
		break;
	case 'day':
		$(m).combobox('enable');
		if(d)$(d).combobox('enable');
		break;
	default:
		alert(model);
	}
}